home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
-
- #include <Components.h>
-
- #include "syslog.h"
-
- #include <GestaltEqu.h>
- #include <Folders.h>
- #include <Processes.h>
-
- #include <stdarg.h>
- #include <string.h>
-
- void main(void){
- OSErr err;
- FSSpec spec;
- long dirid;
- short vref;
-
- printf("Syslog Component Test\n\n");
-
- if (HaveComponentMgr()){
- printf("We have the component mgr\n");
-
- syslog(LOG_INFO,"Syslog Component Test Begin");
-
- printf("Finding the desktop folder\n");
-
- FindFolder(kOnSystemDisk,kDesktopFolderType,kCreateFolder,&vref,&dirid);
-
- FSMakeFSSpec(vref,dirid,
- #if defined(powerc)||defined(__powerc)
- "\pPowerMac Syslog File"
- #else
- "\p68K Syslog File"
- #endif
- ,&spec);
-
- printf("Have an fsspec (vref %d, dirid %ld, name %#s), setting filespec\n",spec.vRefNum,
- spec.parID,spec.name);
-
- // should have a spec, now set the instance up...
- setsyslogfile(&spec);
-
- printf("Set the spec, opening the file\n");
-
- openlog("test",0,LOG_USER);
-
- printf("Writing info into the new log file");
-
- syslog(LOG_INFO,"2 plus 2 is %d",4);
-
- syslog(LOG_CRIT,"Critical Notification!");
-
- syslog(LOG_ERR,"Since this log is created using openlog, it is intialized every time");
- syslog(LOG_ERR,"and will start at a known state. The syslog file in the system folder");
- syslog(LOG_ERR,"does not get reset, it will build up over time, just like the normal syslog");
- syslog(LOG_ERR,"Well, really the unix syslog file is initialized at every restart. I didn't think");
- syslog(LOG_ERR,"that would be very practical for a mac implementation. However, you can");
- syslog(LOG_ERR,"initialize it programmatically by calling openlog right away without changing");
- syslog(LOG_ERR,"the file first");
-
- syslog(LOG_DEBUG,"Test complete");
-
- printf("Writing completed, closing the log\n\n");
-
- closelog();
-
- printf("Log closed\n");
- syslog(LOG_INFO,"Syslog Component Test Complete");
-
- } else {
- printf("No Component Mgr!\n");
- }
-
- fflush(stdout);
-
- return;
- }
-
-